#!/usr/bin/env sh

module_name=eladmin-system

set -a
source ../docker_build.env
set +a

echo "================================================="
echo "image_prefix:${image_prefix}"
echo "================================================="

# 指定镜像tag name
tag_name=${1:-'0.0.1-snapshot'}

# 解析当前代码 git commitid 前7位
commitId=`git rev-parse --short HEAD`

# 组装镜像tag name，样例：0.0.1-snapshot-2a87911
tag_name=${tag_name}-${commitId}

echo "module_name:${module_name}"
echo "tag_name:${tag_name}"

target_tag=${image_prefix}/${module_name}:${tag_name}
echo "target_tag:${target_tag}"

# 构建镜像
docker build -t ${target_tag} .

# 推送镜像到远程仓库
docker push ${target_tag}
